import { saveAllowError } from '@/api/matchFlow.js'

let validRedInvoiceSaveOrSubmit = async(context)=>{
    let handler = context.$refs.fpxxlSP[0];

        let params = {
                "applyId": handler.$store.state.invoice2.invoinceFormStart1.busId,
                "cyjesm": handler.$store.state.fpxxlStore.matchAllowError.cyjesm,
                "yxcyje": handler.$store.state.fpxxlStore.matchAllowError.yxcyje
          }
        let {code} = await  saveAllowError(params);
        return code ==200
  
}





const validFn = {
    "FLOW_PPLS":validRedInvoiceSaveOrSubmit,
}

export async function beforeInvoiceMatchFlow(busType,context){
    return new Promise(async (resolve,reject)=>{
        // 必填校验
        if(busType && validFn[busType]){ // 请求
          try {
            let res = await validFn[busType](context);
            resolve(res)
          } catch (error) {
            resolve(true)
          }

        }else{
            resolve(true)
        }

    })
    
}